home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Graphics / GraphicsWorkshop / Source / Examples / gwcopy / NXBitmapImageRepControl.h < prev    next >
Encoding:
Text File  |  1992-02-01  |  6.1 KB  |  167 lines

  1. #import <objc/Object.h>
  2. #import <sys/param.h>
  3.  
  4. typedef struct {
  5.     char        fullpath[MAXPATHLEN];
  6.     char        type[MAXPATHLEN];
  7. } Type;
  8.  
  9. @interface NXBitmapImageRepControl : Object
  10. {
  11.     int        typesCount;        // number of convertor typers
  12.     int        curMax;            // current maximum # of types. Grow dynamically
  13.     Type    **types;            // Dyanmic array of covnerter types and locations on disk
  14.     Type    *curType    ;        // If one is linked, current type converter, otherwise, NULL
  15.     BOOL    useNeXTStep;    // This variable controls the use of the window manger
  16.  
  17.     id        myView;            // View used in save panel.
  18.     BOOL    amSaving;        // Used to figure out what custom converter view to use.
  19.     id        currentPanel;        // Used to message the current panel.
  20.     id        myBox;            // Holds my custom view in save panel.
  21.     NXRect     viewDefault;        // Default size of my ViewRect.
  22.     id        mySubView;        // Used to handle converters sub view in save panel.
  23.     id        panelSave;        // Used so I can pass the save panel around methods
  24.     id        myPopUp;        // Pop up for save panel.
  25.     id        myButton;        // Button that holds pop.
  26.     id        nameText;        // Used to display format name in Save Panel.
  27.     char        picName[MAXPATHLEN];    // Holds nams of file currently being saved.
  28. }
  29.  
  30. /*
  31.  * Initializes object and scans for converters
  32.  */
  33. - init;
  34.  
  35. /*
  36.  * Deals with linking the correct convertor off of disk.
  37.  * Assumes:    Object has been initialized with a message to init and that inType
  38.  *            is a null terminated pointer to a convertor type that exists in the
  39.  *            convertor list. This list can be accessed via a message to getTypeList.
  40.  *            a filename will have the correct type if it was received via the 
  41.  *            runOpenPanel method.
  42.  * Returns:    self
  43.  */
  44. - handleLink: (char *)inType;
  45.  
  46. /*
  47.  * Runs the open panels.  Returns whatever the openPanel object's
  48.  * runModalForTypes method returns. All filetypes found during init
  49.  * will be valid.
  50.  * Assumes:     Object has been initialized with message to init.
  51.  * Returns:     See OpenPanel.
  52.  */
  53. - (int)runOpenPanel: (id)openPanel;
  54.  
  55. /*
  56.  * Looks at the extension on file filename, links the correct convertor, and
  57.  * loads the image, returning an NXBitmapImageRep.
  58.  * Assumes:     Object initialized with message to init. filename exists on 
  59.  *            disk.
  60.  * Returns:    Id to NXBitmapImageRep on success, or nil on failure.
  61.  */
  62. - (id)openAndReturnImage: (const char *)filename;
  63.  
  64. /*
  65.  * Gets the long name for the currently linked format convertor. This is 
  66.  * useful if you say want the user to read Tagged Image File Format
  67.  * rather than just tiff.
  68.  * Assumes:    Object inited and a convertor has been linked. This is 
  69.  *            Usually accomplished with either a save or open.
  70.  * Returns:    A pointer to a string containing the format name.
  71.  */
  72. - (char *)getCurrentFormatName;
  73.  
  74. /*
  75.  * Runs the save panel for valid types. This also deals with linking in
  76.  * the custom views of the converters and selected different save types.
  77.  * note that after this panel is run, the saveImage method should ne
  78.  * called, otherwise user settings may be forgotten.
  79.  * Assumes:     Object initialized via init message.
  80.  * Returns:    0 if cancel clicked.
  81.  */
  82. - (int)runSavePanel: (id)savePanel withFilename: (const char *)filename;
  83.  
  84. /*
  85.  * Saves "image" named "filename" to disk. Via the correct convertor. The
  86.  * convertor was selected via use of the runSavePanel methods, so this
  87.  * methods should be called immediately afterward, as they're used in sync
  88.  * with each other.
  89.  * Assumes:    Object has been initialized and runSavePanel was the last
  90.  *            message to this object instance.
  91.  * Returns:    YES is object correctly save, NO otherwise.
  92.  */
  93. - (BOOL)saveImage: (id)image toFile: (const char *)filename;
  94.  
  95. /*
  96.  * Give you the filetype list found when object was initialized.
  97.  * Assumes:     Object has been initialized with a call to init.
  98.  * Returns:    Returns a NULL terminated list of pointers to NULL 
  99.  *            terminated strings. This can be passed directly into
  100.  *            the open panel, for example.
  101.  */
  102. - (char **)getTypeList;
  103.  
  104. /*
  105.  * Gets the most recently linked convertor.
  106.  * Assumes:     Object initialized via message to init and that a convertor has
  107.  *            been linked by a message to runSavePanel, handleLink, or
  108.  *            openAndReturnImage.
  109.  * Returns:    id of linked convertor.
  110.  * Notes:        Return is only a pointer to the id. The object will no longer remain
  111.  *            valid after the next link. Also note that it's not recommended to go
  112.  *            go around the save and open methods provided. Calls such as this
  113.  *            one exist primarily for people that need access to special stream
  114.  *            types, and not just filenames.
  115.  */
  116. - getCurrentConverter;
  117.  
  118. /*
  119.  * Methods for converters to call.
  120.  */
  121.  
  122. /*
  123.  * Gets an image control instance. This returned object can be used to
  124.  * perform basic image adjustments like converting Color to B&W or
  125.  * color to 1 bit B&W. See it's header file for details.
  126.  * Assumes:     "image" is a valid NXBitmapImageRep, or ancestor thereof.
  127.  * Returns:    id of image control object.
  128.  */
  129. - getImageControl: (id)image;
  130.  
  131. /*
  132.  * Reports the name of the currently selected file for saving.
  133.  * Assumes:    runSavePanel has been messaged. Also, assumes you
  134.  *            will not modify filename or try and free the pointer returned.
  135.  *            It will remain valid until the next call to runSavePanel, so
  136.  *            you might wish to make a copy.
  137.  * Returns:    A pointer to a null terminated string containing a filename.
  138.  */
  139. - (char *)filename;
  140.  
  141. /*
  142.  * Sets whether or not the control object should attempt to use the window manager.
  143.  * This will be over ridden, under the current release, by functions that intuitively depend
  144.  * on the use of windows, such as the save panel. This may or may not be changed in
  145.  * a future release. However, all error messages will print to stderr when controller is
  146.  * told to not use the window manager. The default value is YES.
  147.  * Assumes:    Object instantiated
  148.  * Results:    If YES, then the window manager must be running. If NO, running the
  149.  *            window manager is optional. In the event that it is not, the converter
  150.  *            will core dump.
  151.  */
  152. - setUseNeXTStep: (BOOL)state;
  153.  
  154. /*
  155.  * Returns whether or not the object will use the window manager.
  156.  * Assumes:    Object instantiated.
  157.  * Returns:    YES, the object will use the window manager, or NO, the object will 
  158.  *            use stderr error for messages.
  159.  */
  160.  - (BOOL)usesNeXTStep;
  161.  
  162. - (int)errorState;
  163.  
  164. - (int)errorMessage;
  165.  
  166. @end
  167.